// pages/dispose/dispose.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    orderList: [],
    storeList:[]
  },
  detailFin: function(e) {
    var orderId = e.currentTarget.dataset.finish;
    wx.redirectTo({
      url: '../finish/finish?userId=' + orderId
    })
  },


  detail: function(e) {
    var index = e.currentTarget.dataset.id;
    var status = e.currentTarget.dataset.status;
    var receiveUserId = e.currentTarget.dataset.receiveuserid;
   
   var arrayList=e.currentTarget.dataset.array;
    var array = JSON.stringify(arrayList)
    var publishId=e.currentTarget.dataset.publishid;
    console.log(index);
    var that = this;
    if(status<=4){
      wx.redirectTo({
        url: '../masterList/masterList?userId=' + publishId + "&receiveUserIdArray=" + array,
      })
    }else{
    wx.redirectTo({
      url: '../servering/servering?userId=' + index + "&receiveUserId=" + receiveUserId
    })
    }
    // wx.setStorageSync("orderDetailId", index)

  },
  request: function() {
    var that = this;
    wx.request({
      url: 'https://www.xiaozheng8.com/serviceOrder/sendFindAll',
      method: "post",
      data: {
        userId:wx.getStorageSync("userId")
      },
      success: function(res) {
        console.log(res.data.data);
        console.log(res.data.data.length)
        for (var i = 0; i < res.data.data.length; i++) {
          if ((res.data.data[i].receiveUserIdArray.length > 0 && res.data.data[i].status == 4) || res.data.data[i].status == 10) {
            that.data.storeList.push(res.data.data[i]);
          }  
        }
        if (that.data.orderList == !that.data.storeList){
          that.setData({
            orderList: that.data.storeList
          })
        }
        console.log(that.data.orderList);
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
   
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    this.request();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  },
  onPullDownRefresh: function() {
    this.request();
    setTimeout(() => {
      wx.stopPullDownRefresh()
    }, 2000)
  }
})